<?php
include("include/config.inc.php");
if(!isset($_SESSION['s_activId']))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
	if(isset($_POST['cityName']))
  {
	  $cityName = isset($_POST['cityName']) ? $_POST['cityName'] : "";
  	$insertCity="INSERT INTO city (city) 
      				         VALUES	('".$cityName."')";
    $insertCityRes = mysql_query($insertCity);
    if(!$insertCityRes)
    {
		  die("not inserted..".mysql_error);    
    }
    else
    {
      header("location:cityEntry.php");
    }
	}
  $cityArray = array();
  $i = 0;
  $selectCity = "SELECT cityId,city
                       FROM city
                       ORDER BY city";
   $selectCityRes = mysql_query($selectCity);
   while($dataRow = mysql_fetch_array($selectCityRes))
   {
     $cityArray[$i]['cityId']   = $dataRow['cityId'];
  	 $cityArray[$i]['city']     = $dataRow['city'];
  	 
  	 $i++;
   }
 }
include("./bottom.php");
$smarty->assign('cityArray',$cityArray);
$smarty->display('cityEntry.tpl');
?>